package com.he.eduservice.controller;


import com.he.commonutils.R;
import com.he.eduservice.entity.EduChapter;
import com.he.eduservice.entity.vo.ChapterVo;
import com.he.eduservice.entity.vo.VideoVo;
import com.he.eduservice.service.EduChapterService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 课程 前端控制器
 * </p>
 *
 * @author testhejinyu
 * @since 2021-06-02
 */
@RestController
@RequestMapping("/eduservice/chapter")
public class EduChapterController {

    @Autowired
    EduChapterService chapterService;

    @ApiOperation(value = "课程大纲的显示")
    @GetMapping("/getVideoList/{courseId}")
    public R getVideoList(@PathVariable("courseId") String courseId) {
        List<ChapterVo> chapterVoList = chapterService.getVideoList(courseId);
        return R.ok().data("list", chapterVoList);
    }

    @ApiOperation(value = "课程大纲添加")
    @PostMapping("/addChapter")
    public R addChapter(@RequestBody EduChapter eduChapter){
        chapterService.addChapter(eduChapter);
        return R.ok();
    }

    @ApiOperation(value = "课程大纲修改")
    @PostMapping("/updateChapter")
    public R updateChapter(@RequestBody EduChapter eduChapter){
        chapterService.updateChapter(eduChapter);
        return R.ok();
    }

    @ApiOperation(value = "课程大纲删除")
    @DeleteMapping("/deleteChapter/{id}")
    public R deleteChapter(@PathVariable String id){
        chapterService.removeChapter(id);
        return R.ok();
    }



}

